package com.example.restfuldemo.controller;

import com.example.restfuldemo.entity.User;
import com.example.restfuldemo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api")
public class UserController {


    @Autowired
    private UserService userService;

    @GetMapping("/all")
    public List<User> getAllUser(){
        return userService.getAllUser();
    }
    @PostMapping("/add")
    public Integer addUser(@RequestBody User user){
        return userService.addUser(user);
    }
    @PutMapping("/update")
    public Integer updateUser(@RequestBody User user){
        return userService.updateUser(user);
    }
    @DeleteMapping("/delete/{id}")
    public Integer deleteUser(@PathVariable("id") Integer id){
        return userService.deleteUser(id);
    }



}
